package gold.contest;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6132 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int minimumOperations(int[] nums) {
            int ans = 0;
            Arrays.sort(nums);
            while (true) {
                int i = 0, minus = -1;
                for (; i < nums.length; i++)
                    if (nums[i] > 0) {
                        minus = nums[i];
                        break;
                    }
                if (minus == -1) break;
                ans++;
                for (; i < nums.length; i++) {
                    nums[i] -= minus;
                }
            }

            return ans;
        }
    }

    public void run() {
        System.out.println(new Solution().minimumOperations(InputUtil.toIntegerArray("[1,5,0,3,5]")));
        System.out.println(new Solution().minimumOperations(InputUtil.toIntegerArray("[0]")));
    }

    public static void main(String[] args) throws Exception {
        LC6132 an = new LC6132();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
